package com.shuhe.handler;

import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.shuhe.JettyServer;
import com.shuhe.common.*;
import com.shuhe.domain.fullText.*;
import com.shuhe.domain.mxgc.CommonResponseBody;
import com.shuhe.metastore.DBSql;
import com.shuhe.metastore.MetaMysql;
import com.shuhe.thread.FullTextThread;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Picture;
import org.apache.poi.ss.usermodel.Sheet;
import sun.misc.BASE64Decoder;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.shuhe.common.CommonFunction.*;
import static com.shuhe.common.MyDateUtils.getNowDate;

public class FullTextHandler extends HttpServlet {

    private static Logger logger = Logger.getLogger(FullTextHandler.class);

    private static int currPort = 0;


    public static void main(String[] args) throws Exception {
//        //String keyValue = "130503197833330333 and 20岁";
//        //String keyValue = "20-40岁 汉 石家庄 130503";
//        String keyValue = "石家庄 or 保定";
//        SqlDomain sqlDomain = analysisSearchvalue(keyValue);
//        ArrayList<SubjectDomain> subjectDomains = fromHttpGetSubjectBySfhm(sqlDomain.getSfhmSql());
//        fromHttpGetZp(subjectDomains.get(0).getGmsfhm());
        for (int i = 0; i < 100; i++) {
            String tmpstr = "姓名为王" + i + " 电话为13722" + i + " 男性";
            FullTextThread thread = new FullTextThread(tmpstr);
            new Thread(thread).start();
        }
    }

    private static ZpDomain fromHttpGetZp(String gmsfhm)
            throws Exception {
        if (!JettyServer.globalProperties.getProperty("product").equals("true")) {
            ZpDomain zpDomain = new ZpDomain();
            zpDomain.setXia_zp("/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAGMAUMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDbJzS8etNOc0fWvZPKv3FznnGKMjoevpSE00nJz3p2uK44nnGKaQB3oyc+9I2O/WmAuV655pA4zTSPl3Ck9+9CBIV29RxSFuKaWDHB7UEjpR0sPqOV+elNbk0nApkkgUCkFgZgOtQyXaJ1IrOudTVGX5j/AN8isSfVJWx+9OPoKzlWj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N/c/WilZhqV8bevepkAwcUicg5pU6GtgY1x83PpSp0z3zSnoaSL7h+tS9h9AYqTtb7xpGwF2j71En3vwqM9ahx6j3QfMD708ZC7v4vWmint/qqznoMduG0E9e9Tq5wOe1Qp/qx9KlP3BU31AmjKgktUttMyO+GwPpVU9BUkPU1NSCcWNaM77R9cZI5czdWH8H/wBau7tb0TfdfPIzxivFLNm2t8x6+td9ojNlvmP3l7150lZmjWh3ofIODUbkjr6VWtGPPPpVmXp+FS2RsQu4bgmq8sZKMFHapT94Up6GpKuY80DZII5+tNjtTvB2/rWvgegp2ABwBT2KuV4oAqD5e3rViNNv3Rg4pR0pB96haslskZmAp4J4xTD0FIOppom5aBqtc3aQoSWx8pPSnHpXHeIGcIuHb7jd6uEb6Ej9a11VjAEx5Rv4P/rVwV5fGVsh8jbjpRdMzAZYng96x5Sd3U9K6YQSGNmkzyD2qucFcnrSv9w1VDHd171rbQLDpD1x1pFLEYNSUdq2gr6CbsIFp2VCAGhPvVKAM1o3bQRED69KVSST6Usn3acnT8KE9AaFVi2aXeB96mmiPkHNArCDBzigFVGD1oj6NSp90/WqYC7WopaKdkKx/9k=");
            return zpDomain;
        }
        //先访问主题库，再访问照片
        String jsonStr = "{\n" +
                "    \"areaCode\": \"\",\n" +
                "    \"messageSequence\": \"\",\n" +
                "    \"condition\": \"gmsfhm='" + gmsfhm + "' and ZHEL_PDBZ" +
                "='1' \",\n" +
                "    \"parafs\": [\n" +
                "    \t\"gmsfhm\",\n" +
                "    \t\"xia_zp\",\n" +
                "    \t\"CSE_PDBZ\",\n" +
                "    \t\"ZHEL_PDBZ\",\n" +
                "    \t\"YU_TUP_GAD_JYQK\",\n" +
                "    \t\"YU_TUP_KDU_JYQK\",\n" +
                "    \t\"fhxtsjwybsid\",\n" +
                "    \t\"cij_rqsj\",\n" +
                "    \t\"sjy_bh\"\n" +
                "    ],\n" +
                "    \"maxReturnNum\": 100\n" +
                "    \n" +
                "}";
        Map<String, String> heads = new HashMap<>();
        heads.put("appId", "A-130100000000-3815");

        String url = "http://131.33.164.101:22580/fhHandler?tab_name=ods_kt_rxkcl_orc_new";
        String respBody = HttpClient.postHttp(url, jsonStr, heads);
        JSONObject bodyJson = JSONObject.parseObject(respBody);
        ArrayList<ZpDomain> zpDomains = new ArrayList<>();
        JSONObject data = (JSONObject) bodyJson.get("data");
        JSONArray results = data.getJSONArray("results");
        for (int i = 0; i < results.size(); i++) {
            JSONObject result = (JSONObject) results.get(i);
            ZpDomain zpDomain =
                    JSONObject.parseObject(result.toJSONString(), ZpDomain.class);
            zpDomain.setWidthHeight(zpDomain.getYU_TUP_GAD_JYQK() + zpDomain.getYU_TUP_KDU_JYQK());
            zpDomains.add(zpDomain);
        }
        Collections.sort(zpDomains);
        Integer yxj = 100;
        Long sj = 0L;
        ZpDomain zpDomainFh = new ZpDomain();
        //找最优照片
        for (int i = 0; i < zpDomains.size(); i++) {
            ZpDomain zpDomain = zpDomains.get(i);
            if (zpDomain.getZHEL_PDBZ().equals("1") &&
                    zpDomain.getCSE_PDBZ().equals("1") &&
                    Integer.valueOf(zpDomain.getYU_TUP_GAD_JYQK()) >= 441 &&
                    Integer.valueOf(zpDomain.getYU_TUP_KDU_JYQK()) >= 358
            ) {
                if (getYxj(zpDomain.getSjy_bh()) <= yxj) {  //数据资源判断
                    if (zpDomain.getCij_rqsj() == null || zpDomain.getCij_rqsj() > sj) {      //时间判断
                        zpDomain.setXia_zp(zpDomain.getXia_zp());
                        yxj = getYxj(zpDomain.getSjy_bh());
                        //sj = zpDomain.getCij_rqsj();
                        zpDomainFh.setXia_zp(zpDomain.getXia_zp());
                        zpDomainFh.setFhxtsjwybsid(zpDomain.getFhxtsjwybsid());
                        if (i < zpDomains.size() - 1) {
                            continue;
                        }
                    } else {
                        if (i < zpDomains.size() - 1) {
                            continue;
                        }
                    }
                }
            } else {
                if (i < zpDomains.size() - 1) {
                    continue;
                }
            }
            //System.out.println(zpDomainFh.getFhxtsjwybsid());
            if (zpDomainFh.getFhxtsjwybsid() == null) {   //对象有值返回
                //System.out.println("没有取到最优");
            } else {
                //System.out.println("最优");
                return zpDomainFh;
            }
        }
        //找次优照片
        for (int i = 0; i < zpDomains.size(); i++) {
            ZpDomain zpDomain = zpDomains.get(i);
            if (zpDomain.getZHEL_PDBZ().equals("1") &&
                    zpDomain.getCSE_PDBZ().equals("1") &&
                    Integer.valueOf(zpDomain.getYU_TUP_GAD_JYQK()) >= 441 / 2 &&
                    Integer.valueOf(zpDomain.getYU_TUP_KDU_JYQK()) >= 358 / 2
            ) {
                if (getYxj(zpDomain.getSjy_bh()) <= yxj) {
                    if (zpDomain.getCij_rqsj() == null || zpDomain.getCij_rqsj() > sj) {
                        zpDomain.setXia_zp(zpDomain.getXia_zp());
                        yxj = getYxj(zpDomain.getSjy_bh());
                        //sj = zpDomain.getCij_rqsj();
                        zpDomainFh.setXia_zp(zpDomain.getXia_zp());
                        zpDomainFh.setFhxtsjwybsid(zpDomain.getFhxtsjwybsid());
                        if (i < zpDomains.size() - 1) {
                            continue;
                        }
                    } else {
                        if (i < zpDomains.size() - 1) {
                            continue;
                        }
                    }
                }
            } else {
                if (i < zpDomains.size() - 1) {
                    continue;
                }
            }
            //System.out.println(zpDomainFh.getFhxtsjwybsid());
            if (zpDomainFh.getFhxtsjwybsid() == null) {
                //System.out.println("没有取到次优");
            } else {
                //System.out.println("次优");
                return zpDomainFh;

            }
        }
        //找有脸照片
        for (int i = 0; i < zpDomains.size(); i++) {
            ZpDomain zpDomain = zpDomains.get(i);
            if (zpDomain.getZHEL_PDBZ().equals("1")
            ) {
                if (getYxj(zpDomain.getSjy_bh()) <= yxj) {
                    if (zpDomain.getCij_rqsj() == null || zpDomain.getCij_rqsj() > sj) {
                        zpDomain.setXia_zp(zpDomain.getXia_zp());
                        yxj = getYxj(zpDomain.getSjy_bh());
                        //sj = zpDomain.getCij_rqsj();
                        zpDomainFh.setXia_zp(zpDomain.getXia_zp());
                        zpDomainFh.setFhxtsjwybsid(zpDomain.getFhxtsjwybsid());
                        if (i < zpDomains.size() - 1) {
                            continue;
                        }
                    } else {
                        if (i < zpDomains.size() - 1) {
                            continue;
                        }
                    }
                }
            } else {
                if (i < zpDomains.size() - 1) {
                    continue;
                }
            }
            //System.out.println(zpDomainFh.getFhxtsjwybsid());
            if (zpDomainFh.getFhxtsjwybsid() == null) {
                //System.out.println("没有取到有脸");
            } else {
                //System.out.println("有脸");
                return zpDomainFh;

            }
        }
        //没找到照片的处理
        ZpDomain zpDomain = new ZpDomain();
        zpDomain.setXia_zp("iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJm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UnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==");
        return zpDomain;
    }

    public static String analysisSql(String sql) {
        int selectPos = sql.indexOf("SELECT ");
        if (selectPos >= 0) {
            sql = sql.substring(selectPos);
            sql = sql.replaceAll("\\\\n", " ");
            int semicolonPos = sql.indexOf(";");
            if (semicolonPos >= 0) {
                sql = sql.substring(0, semicolonPos);
            } else {
                int escPos = sql.indexOf("```");
                if (escPos >= 0) {
                    sql = sql.substring(0, escPos);
                } else {
                    int quotationPos = sql.indexOf("\"");
                    if (quotationPos >= 0) {
                        sql = sql.substring(0, quotationPos);
                    } else {
                        return sql;
                    }
                }
            }
        }
        return sql;
    }

    private static String findStrFromKey(String value, String beforeStr) {
        String findStr = "";
        String tmpstr1 = " " + value + " ";
        //双向循环，先从后开始
        while (tmpstr1.length() > 0) {
            tmpstr1 = tmpstr1.substring(0, tmpstr1.length() - 1);
            String tmpstr = tmpstr1;
            while (tmpstr.length() > 0) {
                if (beforeStr.indexOf(tmpstr) >= 0 && tmpstr.trim().length() > 0) {
                    findStr = tmpstr;
                    break;
                }
                //去掉前面的看看
                tmpstr = tmpstr.substring(1);
            }
            if (findStr.length() > 0) {
                break;
            }
        }
        return findStr;

    }

    private static ArrayList<String> dzToSql(String[] hjdzs, String beforeStr, ArrayList<String> sqls) {
        String tmpSql = "";

        for (int i = 0; i < hjdzs.length; i++) {
            String findStr = findStrFromKey(hjdzs[i], beforeStr);
            if (findStr.length() > 0) {
                tmpSql = tmpSql + " (hjdz = '" + findStr + "' or qtdz = '" + findStr + "') or ";
                continue;
            }
        }
        if (tmpSql.length() > 0) {
            tmpSql = " (" + tmpSql.substring(0, tmpSql.length() - 3) + ") ";
            sqls.add(tmpSql);
        }
        return sqls;
    }


    private static String convertNulltoString(String xm) {
        if (xm == null) {
            xm = "";
        }
        return xm;
    }

    public static SqlDomain analysisSearchvalueByAi(String keyValue) throws Exception {
        long beginTime = Calendar.getInstance().getTimeInMillis();
        ChatQuestion chatQuestion = new ChatQuestion();
        String url = JettyServer.globalProperties.getProperty("chatGLM.api");
        if (url == null) {
            url = "http://131.33.170.69:8000";
        }
        String[] urls = url.split(",");
        int maxPort = urls.length;
        if (currPort >= maxPort) {
            currPort = 0;
        }
        url = urls[currPort];
        currPort++;

        Map<String, String> heads = new HashMap<>();
        String resultStr = "1=2";
        SqlDomain domain = new SqlDomain();
        domain.setSfhmSql(resultStr);
        domain.setLxdhSql("");
        domain.setCphmSql("");
        int jsonIterations = 0;

        while (jsonIterations < 5) {
            jsonIterations++;
            //第一步抽取
            String beforeStr = "### “ " +
                    keyValue.replaceAll("开头", "")
                            .replaceAll("结尾", "")
                            .replaceAll("姓名含", "姓名包含")
                            .replaceAll("包含", "为")
                            .replaceAll("手机", "电话")
                            .replaceAll(" ", "，")
                            .replaceAll("之间", "")
                            .replaceAll("年龄在", "年龄为")
                            .replaceAll("年龄从", "年龄为")
                            .replaceAll("以", "");
            if (beforeStr.indexOf("电话号码") < 0) {
                beforeStr = beforeStr.replaceAll("电话", "电话号码");
            }

            //13b
            String afterStr = " ” \n### {{ 请将上述语句按照JSON格式提取下列信息：" +
                    "‘姓名’，‘电话号码’，‘户籍地址’，‘年龄’，‘民族’，‘身份号码’，‘车牌号码’，" +
                    "‘出生日期’，‘性别’ }}，信息的值用文本表示";
            chatQuestion.setPrompt(beforeStr + afterStr);
            String jsonStr = JSONObject.toJSONString(chatQuestion);
            try {
                String respBody = HttpClient.postHttp(url, jsonStr, heads);
                logger.info(jsonIterations + "第一步抽取:" + keyValue + "\n---结果：\n" + respBody);
                respBody = respBody.replaceAll("\\\\n", "")
                        .replaceAll(" ", "")
                        .replaceAll("json\\{", "{")
                        .replaceAll("\\[未知\\]", "\"\"")
                        .replaceAll("，", ",");
                JSONObject jsonObj = (JSONObject) JSONObject.parse(respBody);
                String responseStr = (String) jsonObj.get("response");
                responseStr = responseStr
                        .replaceAll("未知", "")
                        .replaceAll("包含", "");

                int beginPos = responseStr.indexOf("```{");
                JSONObject response = null;
                if (beginPos < 0) {
                    try {
                        response = JSONObject.parseObject(responseStr);
                    } catch (Exception ex) {
                        logger.info("chatglm 解析不符合预期，继续尝试");
                        continue;
                    }
                } else {
                    int endPos = responseStr.indexOf("}```");
                    responseStr = responseStr.substring(beginPos + 3, endPos + 1);
                    response = JSONObject.parseObject(responseStr);
                }

                Set<String> keys = response.keySet();
                ArrayList<String> responseKeys = new ArrayList<>();
                for (String key : keys) {
                    responseKeys.add(key);
                }

                String xm = response.getString("姓名");
                if (xm == null) {
                    xm = response.getString("name");
                }
                xm = convertNulltoString(xm);
                String xb = response.getString("性别");
                if (xb == null) {
                    xb = response.getString("gender");
                }
                xb = convertNulltoString(xb);
                String gmsfhm = response.getString("身份号码");
                if (gmsfhm == null) {
                    gmsfhm = response.getString("civilIdNumber");
                }
                gmsfhm = convertNulltoString(gmsfhm);
                String lxdh = response.getString("电话号码");
                if (lxdh == null) {
                    lxdh = response.getString("phoneNumber");
                }
                lxdh = convertNulltoString(lxdh);
                String hjdz = response.getString("户籍地址");
                if (hjdz == null) {
                    hjdz = response.getString("householdAddress");
                }
                if (hjdz == null) {
                    hjdz = response.getString("houseAddress");
                }
                if (hjdz == null) {
                    hjdz = response.getString("address");
                }
                hjdz = convertNulltoString(hjdz);

                String nl = response.getString("年龄");
                if (nl == null) {
                    nl = response.getString("ageRanges");
                }
                if (nl == null) {
                    nl = response.getString("ageRange");
                }
                if (nl == null) {
                    nl = response.getString("ageArray");
                }
                if (nl == null) {
                    nl = response.getString("age");
                }
                nl = convertNulltoString(nl);
                String mz = response.getString("民族");
                if (mz == null) {
                    mz = response.getString("ethnicity");
                }
                mz = convertNulltoString(mz);
                String csrq = response.getString("出生日期");
                if (csrq == null) {
                    csrq = response.getString("出生年");
                }
                if (csrq == null) {
                    csrq = response.getString("birthDate");
                }
                csrq = convertNulltoString(csrq);
                String cphm = response.getString("车牌号码");
                if (cphm == null) {
                    cphm = response.getString("vehicleLicensePlateNumber");
                }
                cphm = convertNulltoString(cphm);
                ArrayList<String> sqls = new ArrayList();
                String lxdhSql = "";
                String cphmSql = "";
                String sfhmSql = "";

                if (hjdz.indexOf(xm) >= 0) {
                    xm = "";
                }
                if (cphm.indexOf(hjdz) >= 0 ||
                        !CommonFunction.ifChinese(hjdz)) {
                    hjdz = "";
                }
                if (xm.indexOf(lxdh) >= 0 && lxdh.length() > 0) {
                    xm = "";
                }
                if (xm.length() > 1 &&
                        ChineseCarNumber.getCarCode(xm.substring(0, 1)).length() > 0
                        && calcLetterCount(xm) > 0) {
                    cphm = xm;
                    xm = "";
                }

                xm = findStrFromKey(xm, beforeStr);
                if (xm.length() > 0) {
                    sqls.add(" xm = '" + xm + "' ");
                }
                if (beforeStr.indexOf(xb) >= 0 && xb.length() > 0) {
                    sqls.add(" xb = '" + xb + "' ");
                }

                String[] gmsfhms = replaceStr(gmsfhm).split(",");
                String tmpSql = "";
                for (int i = 0; i < gmsfhms.length; i++) {
                    String tmpstr = gmsfhms[i];
                    while (tmpstr.length() > 0) {
                        if (beforeStr.indexOf(tmpstr) >= 0 &&
                                (beforeStr.indexOf("身份") >= 0 || tmpstr.length() == 18)
                        ) {
                            if (tmpstr.length() == 18) {
                                tmpSql = tmpSql + " gmsfhm = '" + tmpstr + "' or ";
                            } else {
                                tmpSql = tmpSql + " gmsfhm.keyword like '*" + tmpstr + "*' or ";
                            }
                            break;
                        } else {
                            tmpstr = tmpstr.substring(0, tmpstr.length() - 1);
                        }
                    }
                }
                if (tmpSql.length() > 0) {
                    sqls.add(" (" + tmpSql.substring(0, tmpSql.length() - 3) + ") ");
                }

                lxdh = replaceStr(lxdh);
                while (lxdh.length() > 0) {
                    if (beforeStr.indexOf(lxdh) >= 0 &&
                            !(gmsfhm.length() > 11 && gmsfhm.substring(0, 11).equals(lxdh))
                            && (beforeStr.indexOf("电话") >= 0 || beforeStr.indexOf("手机") >= 0 || lxdh.length() == 11)
                    ) {
                        sqls.add(" lxdh.keyword like '*" + lxdh + "*' ");
                        break;
                    } else {
                        lxdh = lxdh.substring(0, lxdh.length() - 1);
                    }
                }
                cphm = cphm.replaceAll(" ", "");
                cphm = findStrFromKey(cphm, beforeStr);
                if (cphm.length() > 0) {
                    sqls.add(" cphm.keyword like '*" + cphm.toUpperCase() + "*' ");
                }

                String[] hjdzs = hjdz.split(",");
                sqls = dzToSql(hjdzs, beforeStr, sqls);

                mz = findStrFromKey(mz, beforeStr);
                if (mz.length() > 0) {
                    sqls.add(" mz = '" + mz + "' ");
                }


                while (csrq.length() > 0) {
                    if (beforeStr.indexOf(csrq) >= 0 && csrq.length() >= 4) {
                        csrq = csrq.replaceAll("年", "-")
                                .replaceAll("月", "-")
                                .replaceAll("日", "");
                        sqls.add(" csrq.keyword like '" + csrq + "*' ");
                        break;
                    } else {
                        csrq = csrq.substring(0, csrq.length() - 1);
                    }
                }

                nl = replaceStr(nl);
                //去掉中文
                for (int j = 0; j < nl.length(); j++) {
                    String tmpstr = nl.substring(j, j + 1);
                    if (CommonFunction.ifChinese(tmpstr)) {
                        nl = nl.substring(j + 1);
                    }
                }
                String[] nls = nl.split(",");
                if (nls[0].length() > 0) {
                    if (nls.length > 1 && beforeStr.indexOf(nls[nls.length - 1]) >= 0
                            && nls[nls.length - 1].length() > 0
                            && beforeStr.indexOf(nls[0]) >= 0) {
                        //年龄从20到23
                        sqls.add(" nl >= " + nls[0] + " and nl <= " + nls[nls.length - 1]);
                    } else {
                        if (beforeStr.indexOf(nls[0]) >= 0 &&
                                (beforeStr.indexOf("岁") >= 0 || beforeStr.indexOf("年龄") >= 0))
                            sqls.add(" nl = " + nls[0]);
                    }
                }


                for (int i = 0; i < sqls.size(); i++) {
                    sfhmSql = sfhmSql + sqls.get(i) + " and ";
                }
                if (sfhmSql.length() > 0) {
                    sfhmSql = sfhmSql.substring(0, sfhmSql.length() - 4);
                } else {
                    sfhmSql = resultStr;
                }

                domain.setCphmSql(cphmSql);
                domain.setLxdhSql(lxdhSql);
                domain.setSfhmSql(sfhmSql);
                long endTime = Calendar.getInstance().getTimeInMillis();
                logger.info("花费时间：" + (endTime - beginTime));
                logger.info("end output:" + sfhmSql + ";" + lxdhSql + ";" + cphmSql);
                return domain;

            } catch (Exception ex) {
                ex.printStackTrace();
                logger.info("chatglm 解析不符合预期，继续尝试");
            }
        }
        return domain;
    }

    private static String replaceStr(String tmpstr) {
        return tmpstr.replaceAll("岁", "")
                .replaceAll("\\[", "")
                .replaceAll("\\]", "")
                .replaceAll("\\n", "")
                .replaceAll(" ", "")
                .replaceAll("-", ",")
                .replaceAll("\\*", "")
                .replaceAll(" ", "")
                .replaceAll("x", "")
                .replaceAll("\"", "")
                .replaceAll("/", "");
    }


    private static SqlDomain analysisSearchvalue(String keyValue) {
        SqlDomain domain = new SqlDomain();

        String lxdhSql = "";
        String cphmSql = "";
        String sfhmSql = "";

        String[] tmps = keyValue.split(" ");
        ArrayList<String> keyValues = new ArrayList();
        for (int i = 0; i < tmps.length; i++) {
            String tmpstr = tmps[i];
            if (tmpstr.length() == 0) {
                continue;
            }
            if (tmpstr.equals("and") || tmpstr.equals("AND")) {
                tmpstr = " and ";
                keyValues.add(tmpstr);
                continue;
            }
            if (tmpstr.equals("or") || tmpstr.equals("OR")) {
                tmpstr = " or ";
                keyValues.add(tmpstr);
                continue;
            }
            if (tmpstr.length() == 18 && calcChineseCount(tmpstr) == 0) {
                tmpstr = " gmsfhm = '" + tmpstr + "' ";
                keyValues.add(tmpstr);
                continue;
            }
            if (tmpstr.indexOf("岁") >= 0) {
                tmpstr = tmpstr.replaceAll("岁", "");
                String[] nls = tmpstr.split("-");
                if (nls.length == 2) {
                    tmpstr = "(nl >= " + nls[0] + " and nl <= " + nls[1] + ")";
                } else {
                    tmpstr = " nl = " + nls[0] + " ";
                }
                keyValues.add(tmpstr);
                continue;
            }
            if (tmpstr.indexOf("-") == 4) {
                if (tmpstr.length() == 10) {
                    tmpstr = " csrq = '" + tmpstr + "' ";
                    keyValues.add(tmpstr);
                    continue;
                } else {
                    tmpstr = " csrq like '*" + tmpstr + "*' ";
                    keyValues.add(tmpstr);
                    continue;
                }

            }
            if (tmpstr.equals("男性") || tmpstr.equals("女性")) {
                tmpstr = " xb = '" + tmpstr + "' ";
                keyValues.add(tmpstr);
                continue;
            }
            String mz = ChineseNationalityCodeUtil.getNationalityCode(tmpstr);
            if (mz.length() > 0) {
                tmpstr = " mz = '" + mz + "' ";
                keyValues.add(tmpstr);
                continue;
            }
            String cphm = ChineseCarNumber.getCarCode(tmpstr.substring(0, 1));
            if (cphm.length() > 0 || calcLetterCount(tmpstr) > 0) {
                tmpstr = " cphm.keyword like '*" +
                        tmpstr.replaceAll("\\*", "".toUpperCase()) + "*' ";
                keyValues.add(tmpstr);
                continue;
            }
            if (calcChineseCount(tmpstr) > 0) {
                if (tmpstr.indexOf("*") >= 0) {
                    //模糊查询
                    tmpstr = tmpstr.replaceAll("\\*", "");
                    tmpstr = " ( hjdz = '" + tmpstr + "' or qtdz = '" + tmpstr
                            + "' or xm = '" + tmpstr + "' ) ";
                    keyValues.add(tmpstr);
                    continue;
                } else {
                    //模糊查询
                    tmpstr = " ( xm = '" + tmpstr + "' or " + " hjdz = '" + tmpstr
                            + "' or qtdz = '" + tmpstr + "' ) ";
                    keyValues.add(tmpstr);
                    continue;
                }

            } else {
                if (tmpstr.length() == 4) {
                    tmpstr = "*" + tmpstr + "*";
                    keyValues.add(" (gmsfhm like '" + tmpstr
                            + "' or csrq like '" + tmpstr
                            + "' or lxdh like '" + tmpstr + "') ");
                } else {
                    tmpstr = "*" + tmpstr + "*";
                    keyValues.add(" (gmsfhm like '" + tmpstr
                            + "' or lxdh like '" + tmpstr + "') ");
                }
                //lxdhSql = " lxdh like '" + tmpstr + "' ";
                continue;
            }

        }
        String whereStr = "";
        for (int i = 0; i < keyValues.size(); i++) {
            String tmpstr = keyValues.get(i);
            if (!whereStr.trim().endsWith(" or") && !whereStr.trim().endsWith(" and") && i > 0) {
                if (!tmpstr.trim().equals("or") && !tmpstr.trim().equals("and")) {
                    whereStr = whereStr + " and ";
                }

            }
            whereStr = whereStr + tmpstr;
        }
        logger.warn("输入：" + keyValue);
        logger.warn("输出：" + whereStr);
        domain.setCphmSql(cphmSql);
        domain.setLxdhSql(lxdhSql);
        domain.setSfhmSql(whereStr);
        return domain;
    }

    private static int calcChineseCount(String str) {
        int count = 0;
        Pattern pattern = Pattern.compile("[\u4e00-\u9fa5]");
        char c[] = str.toCharArray();
        for (int i = 0; i < c.length; i++) {
            Matcher matcher = pattern.matcher(String.valueOf(c[i]));
            if (matcher.matches()) {
                count++;
            }
        }
        return count;
    }

    private static int calcLetterCount(String str) {
        int count = 0;
        Pattern pattern = Pattern.compile("[a-zA-Z]");
        char c[] = str.toCharArray();
        for (int i = 0; i < c.length; i++) {
            Matcher matcher = pattern.matcher(String.valueOf(c[i]));
            if (matcher.matches()) {
                count++;
            }
        }
        return count;
    }


    private static ArrayList<SubjectDomain> fromHttpGetSubjectBySfhm(String analysisStr)
            throws Exception {
        if (!JettyServer.globalProperties.getProperty("product").equals("true")) {
            return initSubject(analysisStr);
        }
        logger.info("begin query subjectDomains data" + MyDateUtils.getNowDate());
        //先访问主题库，再访问照片
        String jsonStr = "{\n" +
                "    \"areaCode\": \"\",\n" +
                "    \"messageSequence\": \"\",\n" +
                "    \"condition\": \"" + analysisStr + "\",\n" +
                "    \"parafs\": [\n" +
                "    \t\"gmsfhm\",\n" +
                "    \t\"xm\",\n" +
                "    \t\"xb\",\n" +
                "    \t\"csrq\",\n" +
                "    \t\"nl\",\n" +
                "    \t\"mz\",\n" +
                "        \"hjdz\",\n" +
                "        \"qtdz\",\n" +
                "        \"lxdh\",\n" +
                "        \"cphm\",\n" +
                "        \"ywsj\",\n" +
                "        \"table_name\",\n" +
                "        \"tjl\",\n" +
                "        \"qz\"\n" +
                "    ],\n" +
                "    \"maxReturnNum\": 100,\n" +
                "    \"orderParafs\": {\n" +
                "        \"qz\": \"asc\"\n" +
                "    }\n" +
                "}";
        Map<String, String> heads = new HashMap<>();
        heads.put("appId", "A-130100000000-3815");
        heads.put("ifOrder", "true");

        String url = "http://131.33.164.101:22580/fhHandler?tab_name=ztk_ry";
        return fromHttpGetSubject(url, jsonStr, heads);
    }

    private static ArrayList<SubjectDomain> fromHttpGetSubjectByLxdh(String analysisStr)
            throws Exception {
        if (!JettyServer.globalProperties.getProperty("product").equals("true")) {
            return initSubjectByLxdh(analysisStr);
        }
        logger.info("begin query subjectDomains data" + MyDateUtils.getNowDate());
        //先访问主题库，再访问照片
        String jsonStr = "{\n" +
                "    \"areaCode\": \"\",\n" +
                "    \"messageSequence\": \"\",\n" +
                "    \"condition\": \"" + analysisStr + "\",\n" +
                "    \"parafs\": [\n" +
                "    \t\"gmsfhm\"\n" +
                "    ],\n" +
                "    \"maxReturnNum\": 100\n" +
                "}";
        Map<String, String> heads = new HashMap<>();
        heads.put("appId", "A-130100000000-3815");
        heads.put("ifOrder", "false");

        String url = "http://131.33.164.101:22580/fhHandler?tab_name=ztk_dh";
        return fromHttpGetSubject(url, jsonStr, heads);
    }

    private static ArrayList<SubjectDomain> fromHttpGetSubjectByCphm(String analysisStr)
            throws Exception {
        if (!JettyServer.globalProperties.getProperty("product").equals("true")) {
            return initSubjectByCphm(analysisStr);
        }
        logger.info("begin query subjectDomains data" + MyDateUtils.getNowDate());
        //先访问主题库，再访问照片
        String jsonStr = "{\n" +
                "    \"areaCode\": \"\",\n" +
                "    \"messageSequence\": \"\",\n" +
                "    \"condition\": \"" + analysisStr + "\",\n" +
                "    \"parafs\": [\n" +
                "    \t\"gmsfhm\"\n" +
                "    ],\n" +
                "    \"maxReturnNum\": 100\n" +
                "}";
        Map<String, String> heads = new HashMap<>();
        heads.put("appId", "A-130100000000-3815");
        heads.put("ifOrder", "false");

        String url = "http://131.33.164.101:22580/fhHandler?tab_name=ztk_jdc";
        return fromHttpGetSubject(url, jsonStr, heads);
    }

    private static ArrayList<SubjectDomain> fromHttpGetSubject(String url, String jsonStr, Map<String, String> heads)
            throws Exception {
        String respBody = HttpClient.postHttp(url, jsonStr, heads);
        JSONObject bodyJson = JSONObject.parseObject(respBody);
        ArrayList<SubjectDomain> subjectDomains = new ArrayList<>();
        JSONObject data = (JSONObject) bodyJson.get("data");
        JSONArray results = data.getJSONArray("results");
        for (int i = 0; i < results.size(); i++) {
            JSONObject result = (JSONObject) results.get(i);
            SubjectDomain subjectDomain =
                    JSONObject.parseObject(result.toJSONString(), SubjectDomain.class);
            subjectDomains.add(subjectDomain);
        }
        logger.info("end query subjectDomains data" + MyDateUtils.getNowDate());
        return subjectDomains;
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {

        Connection metaConn = null;
        Connection dbConn = null;
        try {
            req.setCharacterEncoding("UTF-8");
            String queryString = req.getQueryString();
            String[] querys = queryString.split("&");
            String operate = querys[0].split("=")[1];
            metaConn = MetaMysql.connect();
            if (operate.equals("exportSimple") || operate.equals("exportDetail")) {
                String tableEName = querys[1].split("=")[1];
                String searchKey = querys[2].split("=")[1];
                String rightTable = "";
                CalcCategoryDomain cc = null;
                if (operate.equals("exportSimple")) {
                    String queryType = querys[3].split("=")[1];
                    searchKey = URLDecoder.decode(searchKey);
                    //BASE64Decoder decoder = new BASE64Decoder();
                    //searchKey = new String(decoder.decodeBuffer(searchKey), "UTF-8");
                    ArrayList<SubjectDomain> subjectDomains =
                            analysisSearchvalueBrach(searchKey, queryType, metaConn, "");
                    cc = getCalcCategory(metaConn, tableEName);
                    rightTable = calcRightTable(metaConn, cc, subjectDomains,
                            "simple", null);
                }
                if (operate.equals("exportDetail")) {
                    cc = getCalcCategory(metaConn, tableEName);
                    rightTable = calcRightTable(metaConn, cc, null,
                            "detail", searchKey);
                }
                ExcelWriter writer = ExcelUtil.getWriter(true);
                writer.renameSheet(0, cc.getTopTableCName());
                //写EXECL
                writer = ExportExecl(writer, rightTable, operate, "");
                exportResponse(tableEName, writer, response);
            }
            if (operate.equals("exportArchive")) {
                String zjhm = querys[1].split("=")[1];
                String roleKey = querys[2].split("=")[1];
                //主表
                String sql = "select table_en_name from full_table where archive_order = '100'";
                ResultSet rs = MetaMysql.querySql(metaConn, sql);
                String tableName = "";
                if (rs.next()) {
                    tableName = rs.getString("table_en_name");
                }
                CalcCategoryDomain cc = getCalcCategory(metaConn, tableName);
                String rightTable = calcRightTable(metaConn, cc, null,
                        "archive", zjhm);
                String analysisStr = "gmsfhm = '" + zjhm + "'";
                ArrayList<SubjectDomain> subjectDomains = fromHttpGetSubjectBySfhm(analysisStr);
                SubjectDomain subjectDomain = subjectDomains.get(0);
                ArrayList<TableDomain> tableDomains = new ArrayList<>();
                //基础信息
                sql = "select CONCAT_WS('.',db_schema, table_en_name) table_en_name, table_ch_name, " +
                        "key_col, b.id, b.show_header from full_table a,  full_report b\n" +
                        "where archive_order >= '200' and archive_order < '300' and a.table_en_name = b.table_name";
                ArrayList<TableDomain> tmps = calcTableDomains(sql, metaConn, "jcxx", zjhm);
                tableDomains.addAll(tmps);

                //背景信息
                sql = "select CONCAT_WS('.',db_schema, table_en_name) table_en_name, table_ch_name, " +
                        "key_col, b.id, b.show_header from full_table a,  full_report b\n" +
                        "where archive_order >= '300' and archive_order < '400' and a.table_en_name = b.table_name";
                tmps = calcTableDomains(sql, metaConn, "bjxx", zjhm);
                tableDomains.addAll(tmps);
                //活动信息
                sql = "select CONCAT_WS('.',db_schema, table_en_name) table_en_name, table_ch_name, " +
                        "key_col, b.id, b.show_header from full_table a,  full_report b\n" +
                        "where archive_order >= '400' and archive_order < '500' and a.table_en_name = b.table_name";
                tmps = calcTableDomains(sql, metaConn, "hdxx", zjhm);
                tableDomains.addAll(tmps);

                ExcelWriter writer = ExcelUtil.getWriter(true);
                //写EXECL
                writer.renameSheet(0, cc.getTopTableCName());
                writer = ExportExecl(writer, rightTable, operate, "");
                dbConn = DBSql.connect();
                for (int i = 0; i < tableDomains.size(); i++) {
                    TableDomain td = tableDomains.get(i);
                    sql = "select col_en_name, replace(col_ch_name, ',', '')" +
                            " from full_table_detail_col where table_id = '" +
                            td.getReportId() + "' order by col_order";
                    rs = MetaMysql.querySql(metaConn, sql);
                    String fieldEn = "";
                    String fieldCn = "";
                    while (rs.next()) {
                        fieldEn = fieldEn + rs.getString(1) + ",";
                        fieldCn = fieldCn + rs.getString(2) + ",";
                    }
                    fieldEn = fieldEn.substring(0, fieldEn.length() - 1);
                    fieldCn = fieldCn.substring(0, fieldCn.length() - 1);
                    sql = "select " + fieldEn + " from " + td.getEName() + " where " + td.getKeyCol()
                            + " = '" + zjhm + "'";
                    rs = DBSql.querySql(dbConn, sql);

                    ArrayList<Object> datas = new ArrayList();
                    while (rs.next()) {
                        ArrayList<FieldDomain> fds = new ArrayList<>();
                        String[] colZns = fieldCn.split(",");
                        String[] colEns = fieldEn.split(",");
                        for (int j = 0; j < colZns.length; j++) {
                            FieldDomain fd = new FieldDomain();
                            fd.setName(colZns[j]);
                            String value = rs.getString(colEns[j]);
                            if (value == null) {
                                value = "";
                            }
                            fd.setValue(value);
                            fds.add(fd);
                        }
                        datas.add(fds);
                    }
                    String jsonStr = JSONObject.toJSONString(datas);
                    //写EXECL
                    writer = ExportExecl(writer, jsonStr, operate, td.getCName());
                }
                exportResponse(zjhm, writer, response);

            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            closeDb(metaConn);
            closeDb(dbConn);
        }
    }

    private ExcelWriter ExportExecl(ExcelWriter writer, String rightTable,
                                    String operate, String sheetName) throws Exception {
        if (sheetName.length() > 0) {
            writer.setSheet(sheetName);
        }
        JSONArray ja = JSONObject.parseArray(rightTable);
        ArrayList<Map<String, String>> datas = new ArrayList();
        int maxCol = 9;
        for (int i = 0; i < ja.size(); i++) {
            JSONArray ja1 = JSONObject.parseArray(ja.getString(i));
            Map<String, String> row = new LinkedHashMap<>();
            if (operate.equals("exportDetail") || operate.equals("exportArchive")) {
                maxCol = ja1.size();
            }
            for (int j = 0; j < maxCol; j++) {
                FieldDomain fd = JSONObject.parseObject(ja1.getString(j),
                        FieldDomain.class);
                String name = fd.getName().replaceAll("：", "");
                String value = fd.getValue();
                switch (name) {
                    case "zp":
                        name = "照片";
                        value = "";
                        break;
                    case "zjhm":
                        name = "公民身份号码";
                        break;
                    case "xm":
                        name = "姓名";
                        break;
                }
                row.put(name, value);
            }
            datas.add(row);
        }
        ArrayList<String> zps = new ArrayList<>();
        for (int i = 0; i < datas.size(); i++) {
            Map<String, String> row = datas.get(i);
            String zjhm = row.get("公民身份号码");
            if (zjhm != null) {
                ZpDomain zpDomain = fromHttpGetZp(zjhm);
                zps.add(zpDomain.getXia_zp());
            }
        }


        writer.setDefaultRowHeight(30);
        for (int i = 0; i < zps.size(); i++) {
            String zp = zps.get(i);
            BASE64Decoder decoder = new BASE64Decoder();
            byte[] bytes = decoder.decodeBuffer(zp);
            writePic(writer, 0, i + 1, bytes, HSSFWorkbook.PICTURE_TYPE_JPEG);
        }
        writer.write(datas);
        return writer;
    }

    private void exportResponse(String tableEName, ExcelWriter writer, HttpServletResponse response) throws Exception {
        //设置content—type
        response.setContentType("application/vnd.openxmlformats-officedocument." +
                "spreadsheetml.sheet;charset:utf-8");
        //Content-disposition是MIME协议的扩展，MIME协议指示MIME用户代理如何显示附加的文件。
        response.setHeader("Content-Disposition", "attachment;filename="
                + URLEncoder.encode(tableEName, "UTF-8") + ".xlsx");
        ServletOutputStream outputStream = response.getOutputStream();
        //将Writer刷新到OutPut
        writer.flush(outputStream, true);
        outputStream.close();
        writer.close();

    }

    public void writePic(ExcelWriter writer, int x, int y, byte[] pictureData, int picType) {

        Sheet sheet = writer.getSheet();
        Drawing<?> drawingPatriarch = sheet.createDrawingPatriarch();

        //设置图片单元格位置
        ClientAnchor anchor = drawingPatriarch.createAnchor(0, 0, 255, 255, x, y, x + 1, y + 1);

        //随单元格改变位置和大小
        anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);

        //添加图片
        int pictureIndex = sheet.getWorkbook().addPicture(pictureData, picType);
        Picture picture = drawingPatriarch.createPicture(anchor, pictureIndex);

        //按比例调整图像大小
        picture.resize(1);
    }

    private static ArrayList<SubjectDomain> unionSubject(ArrayList<SubjectDomain> oneDomain,
                                                         ArrayList<SubjectDomain> twoDomain) {
        if (oneDomain.size() == 0) {
            return twoDomain;
        }
        if (twoDomain.size() == 0) {
            return oneDomain;
        }
        ArrayList<SubjectDomain> destList = new ArrayList<>();
        for (SubjectDomain one : oneDomain) {
            for (SubjectDomain two : twoDomain) {
                if (one.getGmsfhm().equals(two.getGmsfhm())) {
                    destList.add(one);
                }
            }
        }
        return destList;
    }

    private static String makeSqlBySubjectDomain(ArrayList<SubjectDomain> destDomain) {
        String lxdhCphmWhere = "";
        if (destDomain.size() > 0) {
            String sql = " gmsfhm in (";
            for (int i = 0; i < destDomain.size(); i++) {
                sql = sql + "'" + destDomain.get(i).getGmsfhm() + "',";
            }
            sql = sql.substring(0, sql.length() - 1) + ")";
            lxdhCphmWhere = sql;
        }
        return lxdhCphmWhere;
    }

    private static ArrayList<SubjectDomain> analysisSearchvalueBrach(String searchKey, String queryType,
                                                                     Connection metaConn, String userId) throws Exception {
        SqlDomain sqlDomain = new SqlDomain();
        String analysisStr = "";
        if (queryType == null) {
            queryType = "rule";
        }
        if (queryType.equals("rule")) {
            sqlDomain = analysisSearchvalue(searchKey);
        }

        if (queryType.equals("ai")) {
            sqlDomain = analysisSearchvalueByAi(searchKey);
        }
        analysisStr = sqlDomain.getSfhmSql() + ";" + sqlDomain.getLxdhSql() + ";" + sqlDomain.getCphmSql();
        //记录搜索记录
        writeLog(metaConn, userId, searchKey + "----" + analysisStr, "searchKey");

        ArrayList<SubjectDomain> subjectDomains = new ArrayList<>();
        if (queryType.equals("ai")) {
            String sfhmSql = sqlDomain.getSfhmSql();
            String lxdhSql = sqlDomain.getLxdhSql();
            String cphmSql = sqlDomain.getCphmSql();
            ArrayList<SubjectDomain> lxdhDomains = new ArrayList<>();
            if (lxdhSql.length() > 0) {
                lxdhDomains = fromHttpGetSubjectByLxdh(lxdhSql);
            }
            ArrayList<SubjectDomain> cphmDomains = new ArrayList<>();
            if (cphmSql.length() > 0) {
                cphmDomains = fromHttpGetSubjectByCphm(cphmSql);
            }
            //取联系电话和车牌号码的合集
            ArrayList<SubjectDomain> destDomain = unionSubject(lxdhDomains, cphmDomains);
            String lxdhCphmWhere = makeSqlBySubjectDomain(destDomain);

            if (sfhmSql.equals("1=2")) {
                if (lxdhCphmWhere.length() > 0) {
                    logger.info("fromHttpGetSubjectBySfhm:-----" + lxdhCphmWhere);
                    subjectDomains = fromHttpGetSubjectBySfhm(lxdhCphmWhere);
                }
            } else {
                if (lxdhCphmWhere.length() > 0) {
                    if (destDomain.size() == 100) {
                        logger.info("fromHttpGetSubjectBySfhm:-----" + sfhmSql + " or " + lxdhCphmWhere);
                        subjectDomains = fromHttpGetSubjectBySfhm(sfhmSql + " or " + lxdhCphmWhere);
                    } else {
                        logger.info("fromHttpGetSubjectBySfhm:-----" + sfhmSql + " and " + lxdhCphmWhere);
                        subjectDomains = fromHttpGetSubjectBySfhm(sfhmSql + " and " + lxdhCphmWhere);
                    }
                } else {
                    logger.info("fromHttpGetSubjectBySfhm:-----" + sfhmSql);
                    subjectDomains = fromHttpGetSubjectBySfhm(sfhmSql);
                }
            }
        } else {
            String sfhmSql = sqlDomain.getSfhmSql();
            String lxdhSql = sqlDomain.getLxdhSql();
            String cphmSql = sqlDomain.getCphmSql();
            String lxdhWhere = "";
            String cphmWhere = "";
            if (lxdhSql.length() > 0) {
                ArrayList<SubjectDomain> lxdhDomains = fromHttpGetSubjectByLxdh(lxdhSql);
                lxdhWhere = makeSqlBySubjectDomain(lxdhDomains);
            }
            if (cphmSql.length() > 0) {
                ArrayList<SubjectDomain> cphmDomains = fromHttpGetSubjectByCphm(cphmSql);
                cphmWhere = makeSqlBySubjectDomain(cphmDomains);
            }
            if (lxdhWhere.length() > 0 && sfhmSql.length() > 0) {
                return fromHttpGetSubjectBySfhm(sfhmSql + " or (" + lxdhWhere + ")");
            }
            if (lxdhWhere.length() <= 0 && sfhmSql.length() > 0) {
                return fromHttpGetSubjectBySfhm(sfhmSql);
            }
            if (lxdhWhere.length() > 0 && sfhmSql.length() <= 0) {
                return fromHttpGetSubjectBySfhm(lxdhWhere);
            }
            if (cphmWhere.length() > 0 && sfhmSql.length() > 0) {
                return fromHttpGetSubjectBySfhm(sfhmSql + " or (" + cphmWhere + ")");
            }
            if (cphmWhere.length() <= 0 && sfhmSql.length() > 0) {
                return fromHttpGetSubjectBySfhm(sfhmSql);
            }
            if (cphmWhere.length() > 0 && sfhmSql.length() <= 0) {
                return fromHttpGetSubjectBySfhm(cphmWhere);
            }

        }
        return subjectDomains;
    }


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        Connection metaConn = null;
        try {
            req.setCharacterEncoding("UTF-8");
            resp = setResponse(resp);
            String bodyStr = readAsChars(req);
            JSONObject bodyJson = JSONObject.parseObject(bodyStr);
            String userId = bodyJson.getString("userId");
            String operate = bodyJson.getString("operate");
            CommonResponseBody commonResp = new CommonResponseBody();
            commonResp.setSuccess();
            metaConn = MetaMysql.connect();
            if (operate.equals("isFirstAccess")) {
                String sql = "select count(1) from full_search_log where user_id = '"
                        + userId + "'";
                ResultSet rs = MetaMysql.querySql(metaConn, sql);
                rs.next();
                int count = rs.getInt(1);
                if (count <= 0) {
                    commonResp.setExtraStr("true");
                } else {
                    commonResp.setExtraStr("false");
                }
                String respJson = JSONObject.toJSONString(commonResp);
                resp.getWriter().write(respJson);
            }
            if (operate.equals("getUser")) {
                userId = bodyJson.getString("token");
                logger.info("one:" + userId);
                String key = "tongc" + MyDateUtils.getNowDate().substring(0, 10);
                try {
                    userId = EncryptUtils.decrypt(userId, key);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                String sql = "select login_name from sys_user where login_name = '" + userId + "'";
                ResultSet rs = MetaMysql.querySql(metaConn, sql);
                if (!rs.next()) {
                    userId = "";
                } else {
                    String roleStr = getRoleStr(userId, metaConn);
                    userId = userId + "|" + roleStr;
                }
                FullTextResponse res = new FullTextResponse();
                commonResp.setExtraStr(userId);
                res.setCommon(commonResp);
                String respJson = JSONObject.toJSONString(res);
                resp.getWriter().write(respJson);
            }
            if (operate.equals("getZp")) {
                String zjhm = bodyJson.getString("zjhm");
                ZpDomain zpDomain = fromHttpGetZp(zjhm);
                commonResp.setExtraStr(zpDomain.getXia_zp());
                FullTextResponse res = new FullTextResponse();
                res.setCommon(commonResp);
                String respJson = JSONObject.toJSONString(res);
                resp.getWriter().write(respJson);
            }
            if (operate.equals("searchKey")) {
                String searchKey = bodyJson.getString("searchKey");
                String queryType = bodyJson.getString("queryType");
                ArrayList<SubjectDomain> subjectDomains =
                        analysisSearchvalueBrach(searchKey, queryType, metaConn, userId);

                //计算左边的分类
                CalcCategoryDomain cc = calcLeftCategory(metaConn, subjectDomains);
                String rightTable = calcRightTable(metaConn, cc, subjectDomains,
                        "simple", null);
                //组装返回数据
                if (rightTable.equals("no found")) {
                    commonResp.setFail("没有找到满足条件的数据");
                }
                String respJson = getResponse(commonResp, subjectDomains, rightTable, cc);
                resp.getWriter().write(respJson);
            }
            if (operate.equals("selectTable")) {
                String tableName = bodyJson.getString("tableName");
                //记录查看简表
                writeLog(metaConn, userId, tableName, "selectTable");
                ArrayList<SubjectDomain> subjectDomains = getSubjectDomains(bodyJson);
                CalcCategoryDomain cc = getCalcCategory(metaConn, tableName);
                String rightTable = calcRightTable(metaConn, cc, subjectDomains,
                        "simple", null);
                //组装返回数据
                String respJson = getResponse(commonResp, subjectDomains, rightTable, cc);
                resp.getWriter().write(respJson);
            }
            if (operate.equals("showDetail")) {
                String tableName = bodyJson.getString("tableEName");
                String id = bodyJson.getString("id");
                //记录查看明细
                writeLog(metaConn, userId, tableName, "showDetail");
                //ArrayList<SubjectDomain> subjectDomains = getSubjectDomains(bodyJson);
                CalcCategoryDomain cc = getCalcCategory(metaConn, tableName);
                String rightTable = calcRightTable(metaConn, cc, null,
                        "detail", id);
                //组装返回数据
                String respJson = getResponse(commonResp, null, rightTable, cc);
                resp.getWriter().write(respJson);
            }
            if (operate.equals("showArchive")) {
                String zjhm = bodyJson.getString("zjhm");
                String roleKey = bodyJson.getString("roleKey");
                //记录查看档案
                writeLog(metaConn, userId, zjhm, "showArchive");
                //主表
                String sql = "select table_en_name from full_table where archive_order = '100'";
                ResultSet rs = MetaMysql.querySql(metaConn, sql);
                String tableName = "";
                if (rs.next()) {
                    tableName = rs.getString("table_en_name");
                }
                CalcCategoryDomain cc = getCalcCategory(metaConn, tableName);
                String rightTable = calcRightTable(metaConn, cc, null,
                        "archive", zjhm);
                String analysisStr = "gmsfhm = '" + zjhm + "'";
                ArrayList<SubjectDomain> subjectDomains = fromHttpGetSubjectBySfhm(analysisStr);
                SubjectDomain subjectDomain = subjectDomains.get(0);
                ArrayList<TableDomain> tableDomains = new ArrayList<>();
                //基础信息
                sql = "select table_en_name, table_ch_name, key_col, b.id, b.show_header " +
                        "from full_table a,  full_report b\n" +
                        "where archive_order >= '200' and archive_order < '300' " +
                        "and a.id = b.id order by archive_order + 0";
                ArrayList<TableDomain> tmps = calcTableDomains(sql, metaConn, "jcxx", zjhm);
                tableDomains.addAll(tmps);
                //背景信息
                sql = "select table_en_name, table_ch_name, key_col, b.id, b.show_header" +
                        " from full_table a,  full_report b\n" +
                        "where archive_order >= '300' and archive_order < '400' " +
                        "and a.id = b.id  order by archive_order + 0";
                tmps = calcTableDomains(sql, metaConn, "bjxx", zjhm);
                tableDomains.addAll(tmps);
                //活动信息
                sql = "select table_en_name, table_ch_name, key_col, b.id, b.show_header" +
                        " from full_table a,  full_report b\n" +
                        "where archive_order >= '400' and archive_order < '500' " +
                        "and a.id = b.id  order by archive_order + 0";
                tmps = calcTableDomains(sql, metaConn, "hdxx", zjhm);
                tableDomains.addAll(tmps);

                tableDomains = analysisSubjectDomain(subjectDomain, tableDomains);
                cc.setTableDomains(tableDomains);
                //计数全部轨迹

                int pos = -1;
                for (int i = tableDomains.size() - 1; i >= 0; i--) {
                    if (tableDomains.get(i).getEName().equals("ads_hb_gj")) {
                        pos = i;
                        break;
                    }
                }
                if (pos > 0) {
                    int cun = 0;
                    for (int i = pos + 1; i < tableDomains.size(); i++) {
                        cun = cun + tableDomains.get(i).getCount();
                    }
                    tableDomains.get(pos).setCount(cun);
                }
                //组装返回数据
                String respJson = getResponse(commonResp, null, rightTable, cc);
                resp.getWriter().write(respJson);
            }
        } catch (Exception ex) {
            resp.getWriter().write(returnFail(ex.getMessage()));
            logger.info(ex.getMessage());
            ex.printStackTrace();
        } finally {
            closeDb(metaConn);
        }

    }

    private static ArrayList<TableDomain> calcTableDomains(String sql, Connection metaConn,
                                                           String categoryEName, String zjhm) throws Exception {
        ResultSet rs = MetaMysql.querySql(metaConn, sql);
        ArrayList<TableDomain> tableDomains = new ArrayList<>();
        while (rs.next()) {
            TableDomain td = new TableDomain();
            td.setEName(rs.getString("table_en_name"));
            td.setCName(rs.getString("table_ch_name"));
            td.setKeyCol(rs.getString("key_col"));
            String parameter = "\"" + rs.getString("key_col") + "\":\"" + zjhm + "\"";
            td.setReportParameter(parameter);
            td.setReportId(rs.getString("id"));
            td.setCategoryEName(categoryEName);
            if (rs.getString("show_header").equals("true")) {
                td.setShowHeader(true);
            } else {
                td.setShowHeader(false);
            }

            tableDomains.add(td);
        }
        return tableDomains;
    }


    private static String getResponse(CommonResponseBody commonResp,
                                      ArrayList<SubjectDomain> subjectDomains,
                                      String rightTable, CalcCategoryDomain cc) {
        FullTextResponse res = new FullTextResponse();
        res.setSubjectDomains(subjectDomains);
        res.setRightTable(rightTable);
        res.setTableCName(cc.getTopTableCName());
        res.setTableEName(cc.getTopTableEName());
        res.setTableDomains(cc.getTableDomains());
        res.setCategoryDomains(cc.getCategoryDomains());
        res.setCommon(commonResp);
        String respJson = JSONObject.toJSONString(res);
        return respJson;
    }

    private static CalcCategoryDomain getCalcCategory(Connection metaConn, String tableName) throws Exception {
        String sql = "select concat_ws('.', db_schema, table_en_name) as table_en_name, table_ch_name, " +
                "key_col, order_col, primary_col from full_table\n" +
                "where table_en_name = '" + tableName + "'";
        ResultSet rs = MetaMysql.querySql(metaConn, sql);
        CalcCategoryDomain cc = new CalcCategoryDomain();
        if (rs.next()) {
            cc.setTopTableCName(rs.getString("table_ch_name"));
            String table_en_name = rs.getString("table_en_name");
            cc.setTopQueryTable(table_en_name);
            String[] tmpstr = table_en_name.split("\\.");
            cc.setTopTableEName(tmpstr[1]);
            cc.setKeyCol(rs.getString("key_col"));
            cc.setOrderCol(rs.getString("order_col"));
            cc.setPrimayCol(rs.getString("primary_col"));
        }
        return cc;
    }

    private static ArrayList<SubjectDomain> getSubjectDomains(JSONObject bodyJson) {
        JSONArray jas = bodyJson.getJSONArray("subjectDomains");
        ArrayList<SubjectDomain> subjectDomains = new ArrayList<>();
        for (int i = 0; i < jas.size(); i++) {
            SubjectDomain sd = JSONObject.parseObject(jas.get(i).toString(), SubjectDomain.class);
            subjectDomains.add(sd);
        }
        return subjectDomains;

    }

    private static void writeLog(Connection metaConn, String userId, String operate_key, String operate) throws Exception {
        //记录查看记录
        String sql = "insert into full_search_log(id, user_id, operate_key, operate_type, update_time) " +
                "values('" + UUID.randomUUID().toString().replace("-", "") +
                "','" + userId.replaceAll("'", "") + "','" + operate_key.replaceAll("'", "") + "','"
                + operate + "','" + getNowDate() + "')";
        MetaMysql.execSql(metaConn, sql);
    }

    private static ArrayList<String> getZjhm(ArrayList<SubjectDomain> subjectDomains) {
        ArrayList<String> zjhms = new ArrayList<>();
        for (int i = 0; i < subjectDomains.size(); i++) {
            SubjectDomain sd = subjectDomains.get(i);
            if (zjhms.indexOf(sd.getGmsfhm()) < 0) {
                zjhms.add(sd.getGmsfhm());
            }
        }
        return zjhms;
    }

    private static String calcRightTable(Connection metaConn, CalcCategoryDomain cc,
                                         ArrayList<SubjectDomain> subjectDomains,
                                         String operateType, String whereValue) throws Exception {
        Connection dbConn = null;
        try {
            dbConn = DBSql.connect();
            String sql = "select a.col_en_name, a.col_ch_name, a.col_order, b.table_en_name \n" +
                    "from full_table_simple_col a, full_table b \n" +
                    "where a.table_id = b.id and " +
                    "concat_ws('.', b.db_schema, b.table_en_name) = '" + cc.getTopQueryTable() + "'\n" +
                    "order by a.col_order + 0";
            if (operateType.equals("detail")) {
                sql = sql.replaceAll("full_table_simple_col", "full_table_detail_col");
            }
            if (operateType.equals("archive")) {
                sql = sql.replaceAll("full_table_simple_col", "full_table_archive_col");
            }
            ArrayList<String> colCns = new ArrayList<>();
            ArrayList<String> colEns = new ArrayList<>();
            ResultSet rs = MetaMysql.querySql(metaConn, sql);
            String field = "";
            String[] orderCols = cc.getOrderCol().split(",");


            while (rs.next()) {
                String tmpstr = rs.getString("col_en_name");
                if (tmpstr.length() > 0) {
                    if (arrayIndex(orderCols, tmpstr) < 0 &&
                            !cc.getKeyCol().equals(tmpstr) &&
                            !cc.getPrimayCol().equals(tmpstr)) {
                        field = field + tmpstr + ",";
                    }
                    colEns.add(rs.getString("col_en_name"));
                    colCns.add(rs.getString("col_ch_name"));
                }
            }
            field = field.substring(0, field.length() - 1);
            String mustCol = cc.getKeyCol();
            for (int k = 0; k < orderCols.length; k++) {
                if (mustCol.indexOf(orderCols[k]) < 0) {
                    mustCol = mustCol + "," + orderCols[k];
                }
            }

            if (mustCol.indexOf(cc.getPrimayCol()) < 0) {
                mustCol = mustCol + "," + cc.getPrimayCol();
            }

            if (operateType.equals("detail")) {
                sql = "select " + field + "," + mustCol + " from " + cc.getTopQueryTable()
                        + " where " + cc.getPrimayCol() + " = '" + whereValue + "'";
            }
            if (operateType.equals("archive")) {
                sql = "select " + field + "," + mustCol + " from " + cc.getTopQueryTable()
                        + " where " + cc.getKeyCol() + " = '" + whereValue + "'";
            }
            if (operateType.equals("simple")) {
                ArrayList<String> zjhms = getZjhm(subjectDomains);
                if (zjhms.size() == 0) {
                    return "no found";
                }
                String zjhm1 = "";
                String zjhm2 = "";
                String zjhm3 = "";
                for (int i = 0; i < zjhms.size(); i++) {
                    if (i < 35) {
                        zjhm1 = zjhm1 + "'" + zjhms.get(i) + "',";
                    }
                    if (i >= 35 && i < 70) {
                        zjhm2 = zjhm2 + "'" + zjhms.get(i) + "',";
                    }
                    if (i >= 70) {
                        zjhm3 = zjhm3 + "'" + zjhms.get(i) + "',";
                    }
                }
                if (zjhm1.length() > 3) {
                    zjhm1 = zjhm1.substring(0, zjhm1.length() - 1);
                    sql = " (select " + field + "," + mustCol + " from " + cc.getTopQueryTable()
                            + " where " + cc.getKeyCol() + " in (" + zjhm1 + ") " +
                            "order by " + cc.getOrderCol() + ") a";
                }
                if (zjhm2.length() > 3) {
                    zjhm2 = zjhm2.substring(0, zjhm2.length() - 1);
                    sql = sql + " union (select " + field + "," + mustCol + "  from "
                            + cc.getTopQueryTable()
                            + " where " + cc.getKeyCol() + " in (" + zjhm2 + ") " +
                            " order by " + cc.getOrderCol() + ")";
                }
                if (zjhm3.length() > 3) {
                    zjhm3 = zjhm3.substring(0, zjhm3.length() - 1);
                    sql = sql + " union (select " + field + "," + mustCol + "  from "
                            + cc.getTopQueryTable()
                            + " where " + cc.getKeyCol() + " in (" + zjhm3 + ") " +
                            "order by " + cc.getOrderCol() + ")";
                }
                sql = "select * from " + sql;
            }
            //查询表数据
            logger.info("begin query postgresql" + MyDateUtils.getNowDate());
            rs = DBSql.querySql(dbConn, sql);
            logger.info("end query postgresql" + MyDateUtils.getNowDate());
            ArrayList<Object> datas = new ArrayList();
            while (rs.next()) {
                String zjhm = rs.getString(cc.getKeyCol());
                ArrayList<FieldDomain> fds = new ArrayList<>();

                if (operateType.equals("simple")) {
                    SubjectDomain sd = getSubjectDomain(subjectDomains, zjhm);
                    FieldDomain fd = new FieldDomain();
                    fd.setName("zp");
                    fd.setValue(sd.getZp());
                    fds.add(fd);

                    fd = new FieldDomain();
                    fd.setName("xm");
                    fd.setValue(sd.getXm());
                    fds.add(fd);

                    fd = new FieldDomain();
                    fd.setName("zjhm");
                    fd.setValue(sd.getGmsfhm());
                    fds.add(fd);
                }
                if (operateType.equals("detail") || operateType.equals("archive")) {
                    //从ES中得到照片
                    FieldDomain fd = new FieldDomain();
                    ZpDomain zpDomain = fromHttpGetZp(zjhm);
                    fd.setName("zp");
                    fd.setValue(zpDomain.getXia_zp());
                    fds.add(fd);
                }
                for (int i = 0; i < colEns.size(); i++) {
                    FieldDomain fd = new FieldDomain();
                    if (operateType.equals("simple")) {
                        fd.setName(colCns.get(i) + "：");
                    } else {
                        fd.setName(colCns.get(i));
                    }
                    String value = rs.getString(colEns.get(i));
                    if (value == null) {
                        value = "";
                    }
                    fd.setValue(value);
                    fds.add(fd);
                }
                if (operateType.equals("simple")) {
                    while (fds.size() < 9) {
                        FieldDomain fd = new FieldDomain();
                        fd.setName("");
                        fd.setValue("");
                        fds.add(fd);
                    }
                    //设置主键，用于展现明细信息
                    FieldDomain fd = new FieldDomain();
                    fd.setName("primaryCol");
                    fd.setValue(rs.getString(cc.getPrimayCol()));
                    fds.add(fd);
                    //设置证件号码，用于展现档案
                    fd = new FieldDomain();
                    fd.setName("keyCol");
                    fd.setValue(rs.getString(cc.getKeyCol()));
                    fds.add(fd);
                }
                datas.add(fds);
            }
            String jsonStr = JSONObject.toJSONString(datas);
            return jsonStr;
        } finally {
            closeDb(dbConn);
        }
    }

    private static int arrayIndex(String[] orderCols, String searchStr) {
        for (int i = 0; i < orderCols.length; i++) {
            if (orderCols[i].equals(searchStr)) {
                return i;
            }
        }
        return -1;
    }

    private static SubjectDomain getSubjectDomain(ArrayList<SubjectDomain> subjectDomains, String zjhm) {
        for (int i = 0; i < subjectDomains.size(); i++) {
            SubjectDomain sd = subjectDomains.get(i);
            if (sd.getGmsfhm().equals(zjhm)) {
                return sd;
            }
        }
        return null;
    }

    //计算分类、表的记录个数
    private static CalcCategoryDomain calcLeftCategory(Connection metaConn, ArrayList<SubjectDomain> subjectDomains)
            throws Exception {
        ArrayList<TableDomain> tableDomains = new ArrayList<>();
        ArrayList<CategoryDomain> categoryDomains = new ArrayList<>();
        String topQueryTable = "";
        String topTableCName = "";
        String topTableEName = "";
        String key_col = "";
        String order_col = "";
        String primary_col = "";
        String sql = "select db_schema, table_en_name, table_ch_name, table_category as category_en_name, " +
                "b.name category_ch_name, table_order, key_col, order_col, primary_col\n" +
                "from full_table a, full_category b where a.table_category = b.id\n" +
                "order by a.table_order + 0";
        ResultSet rs = MetaMysql.querySql(metaConn, sql);
        int k = 0;
        while (rs.next()) {
            TableDomain td = new TableDomain();
            td.setCategoryCName(rs.getString("category_ch_name"));
            td.setCategoryEName(rs.getString("category_en_name"));
            td.setCName(rs.getString("table_ch_name"));
            td.setEName(rs.getString("table_en_name"));
            td.setOrder(rs.getInt("table_order"));
            tableDomains.add(td);
            if (k == 0) {
                topQueryTable = rs.getString("db_schema") + "." + td.getEName();
                key_col = rs.getString("key_col");
                order_col = rs.getString("order_col");
                primary_col = rs.getString("primary_col");
                topTableCName = td.getCName();
                topTableEName = td.getEName();
            }
            k++;
        }
        for (int i = 0; i < subjectDomains.size(); i++) {
            SubjectDomain sd = subjectDomains.get(i);
            tableDomains = analysisSubjectDomain(sd, tableDomains);
        }
        calcCategoryCount(tableDomains, categoryDomains);
        CalcCategoryDomain cc = new CalcCategoryDomain();
        cc.setCategoryDomains(categoryDomains);
        cc.setTableDomains(tableDomains);
        cc.setTopQueryTable(topQueryTable);
        cc.setKeyCol(key_col);
        cc.setOrderCol(order_col);
        cc.setPrimayCol(primary_col);
        cc.setTopTableCName(topTableCName);
        cc.setTopTableEName(topTableEName);
        return cc;

    }

    public static ArrayList<TableDomain> analysisSubjectDomain(SubjectDomain sd,
                                                               ArrayList<TableDomain> tableDomains) {

        String zy = sd.getTjl();
        try {
            String[] zys = zy.split(",");
            for (int j = 0; j < zys.length; j++) {
                String leftStr = zys[j].split(":")[0].trim();
                String rightStr = zys[j].split(":")[1].trim();
                tableDomains = calcTableCount(tableDomains, leftStr, rightStr);
            }
            return tableDomains;
        } catch (Exception ex) {
            logger.info("tjl exception:'" + zy + "'");
        }
        return tableDomains;
    }


    private static ArrayList<TableDomain> calcTableCount(ArrayList<TableDomain> tableDomains, String leftStr, String rightStr) {
        for (int i = 0; i < tableDomains.size(); i++) {
            TableDomain td = tableDomains.get(i);
            String eName = td.getEName();
            if (eName.equals(leftStr)) {
                int cun = td.getCount() + Integer.parseInt(rightStr);
                td.setCount(cun);
                tableDomains.set(i, td);
            }
        }
        return tableDomains;
    }

    private static void calcCategoryCount(ArrayList<TableDomain> tableDomains, ArrayList<CategoryDomain> categoryDomains) {
        for (int i = 0; i < tableDomains.size(); i++) {
            TableDomain td = tableDomains.get(i);
            CategoryDomain cd = new CategoryDomain();
            cd.setCName(td.getCategoryCName());
            cd.setEName(td.getCategoryEName());
            cd.setCount(0);
            boolean isExist = false;
            for (int j = 0; j < categoryDomains.size(); j++) {
                CategoryDomain cd1 = categoryDomains.get(j);
                if (cd.getEName().equals(cd1.getEName())) {
                    isExist = true;
                }
            }
            if (!isExist) {
                categoryDomains.add(cd);
            }
        }
        for (int j = 0; j < categoryDomains.size(); j++) {
            CategoryDomain cd = categoryDomains.get(j);
            for (int i = 0; i < tableDomains.size(); i++) {
                TableDomain td = tableDomains.get(i);
                if (cd.getEName().equals(td.getCategoryEName())) {
                    int cun = td.getCount() + cd.getCount();
                    cd.setCount(cun);
                    categoryDomains.set(j, cd);
                }
            }
        }
    }

    private static ArrayList<SubjectDomain> initSubject(String analysisStr) {
        ArrayList<SubjectDomain> subjectDomains = new ArrayList<>();
        try {
            Connection conn = MetaMysql.connect();
            String sql = "select gmsfhm, xm, tjl  from formal.ztk_ry_new where "
                    + analysisStr.replaceAll(".keyword", "");
            ResultSet rs = MetaMysql.querySql(conn, sql);
            while (rs.next()) {
                SubjectDomain subjectDomain = new SubjectDomain();
                subjectDomain.setGmsfhm(rs.getString("gmsfhm"));
                subjectDomain.setXm(rs.getString("xm"));
                subjectDomain.setTjl(rs.getString("tjl"));
                subjectDomains.add(subjectDomain);
            }
            return subjectDomains;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return subjectDomains;
    }

    private static ArrayList<SubjectDomain> initSubjectByLxdh(String analysisStr) {
        ArrayList<SubjectDomain> subjectDomains = new ArrayList<>();
        try {
            Connection conn = MetaMysql.connect();
            String sql = "select gmsfhm from formal.ztk_dh where "
                    + analysisStr.replaceAll(".keyword", "");
            ResultSet rs = MetaMysql.querySql(conn, sql);
            while (rs.next()) {
                SubjectDomain subjectDomain = new SubjectDomain();
                subjectDomain.setGmsfhm(rs.getString("gmsfhm"));
                subjectDomains.add(subjectDomain);
            }
            return subjectDomains;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return subjectDomains;
    }

    private static ArrayList<SubjectDomain> initSubjectByCphm(String analysisStr) {
        ArrayList<SubjectDomain> subjectDomains = new ArrayList<>();
        try {
            Connection conn = MetaMysql.connect();
            String sql = "select gmsfhm from formal.ztk_jdc where "
                    + analysisStr.replaceAll(".keyword", "");
            ResultSet rs = MetaMysql.querySql(conn, sql);
            while (rs.next()) {
                SubjectDomain subjectDomain = new SubjectDomain();
                subjectDomain.setGmsfhm(rs.getString("gmsfhm"));
                subjectDomains.add(subjectDomain);
            }
            return subjectDomains;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return subjectDomains;
    }

    private static Integer getYxj(String keyValue) {
        Integer yxj = 100;
        if (keyValue.equals("#R-130100000000-00005004#")) {
            yxj = 1;
        } else if (keyValue.equals("#R-130100000000-00003938#")) {
            yxj = 2;
        } else if (keyValue.equals("#R-130100000000-00002163#")) {
            yxj = 3;

        } else if (keyValue.equals("#R-130100000000-00002388#")) {
            yxj = 4;

        } else if (keyValue.equals("#R-130100000000-00004352#")) {
            yxj = 5;

        } else if (keyValue.equals("#R-130100000000-00002242#")) {
            yxj = 6;

        } else if (keyValue.equals("#R-130100000000-00001801#")) {
            yxj = 7;

        } else if (keyValue.equals("#R-130100000000-00004350#")) {
            yxj = 8;

        } else if (keyValue.equals("#R-130100000000-00004354#")) {
            yxj = 9;

        } else if (keyValue.equals("#R-130100000000-00004474#")) {
            yxj = 10;

        } else if (keyValue.equals("#R-130100000000-00004472#")) {
            yxj = 11;

        } else if (keyValue.equals("#R-130100000000-00004346#")) {
            yxj = 12;

        } else if (keyValue.equals("#R-130100000000-00001897#")) {
            yxj = 13;

        } else if (keyValue.equals("#R-130100000000-00004343#")) {
            yxj = 14;

        } else {
            yxj = 100;

        }
        return yxj;
    }


}
